<?php
/*
 * this contains tables to list orders or returns and form to update item stack
 */

//this will display all orders that is not edited
function getOrders($db) {
    $res = $db->query('SELECT * from orders WHERE sendingdate LIKE \'0001-01-01 00:00:00\' ORDER BY orderdate DESC');
    echo '<h1>Ubehandlet bestillinger</h1>'; //get all orders that is not edited
    echo '<table id="getOrderTable">';
    echo "<tr><th>ordre ID</th><th>Ordre dato</th></tr>";
    while ($row = $res->fetch()) { //list the order values that are important
        echo '<tr>';
        echo '<td><a href="employeeViews/empEditOrder.php?orderID=' . $row['oid'] . '">' . $row['oid'] . '</a></td>';
        echo '<td>' . $row['orderdate'] . '</td>';
        echo '<tr>';
    }
    echo '</table>';
}

//this will display the form to update the stock for one item
function updateItemStack($db) {
    echo '<h1>Oppdater lagerstatus</h1>';
    echo '<form name="updateStock" method="post" action="myEmpSite.php" >';
    echo '<label for="givenname">Vare ID:</label><input type="text" name="itemID" >';
    echo '<label for="givenname">Hvor mange varer skal legges til:</label><input type="number" name="stock" value="1" >';
    echo '<input type="submit" name="update" value="Oppdater" >';
    echo '</form>';
}

//this will display return search options
function getReturns($db) {
    echo '<h1>Søk etter retur</h1>';
    echo '<form name="editReturns" method="post" action="myEmpSite.php" >';
    echo '<label for="orderID">Ordre ID:</label><input type="text" name="orderID" >';    
    echo '<label for="returID">Retur ID:</label><input type="text" name="returID" >';
    echo '<label for="userID">Bruker ID:</label><input type="text" name="userID" >';
    echo '<input type="submit" name="sok" value="søk" >';
    echo '</form>';
}

?>
